package ycl.important.controller.hovel;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import ycl.important.common.ApiResult;
import ycl.important.common.models.req.base.ObjReq;
import ycl.important.common.models.tencent.maps.Location;
import ycl.important.common.models.tencent.maps.req.ExploreReq;
import ycl.important.common.models.tencent.maps.req.PlaceSearchReq;
import ycl.important.common.models.tencent.maps.req.SuggestionReq;
import ycl.important.common.models.tencent.maps.res.*;
import ycl.important.service.hovel.GpsService;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * 定位 前端控制器
 *
 * @author: YCL
 * @date: 2021-09-10 00:22:19
 */
@RestController
@RequestMapping("/hovel/gps")
@Api(tags = "定位")
@ApiSort(31)
public class GpsController {

	@Resource
	private GpsService gpsService;


	@PostMapping("/placeSearch")
	@ApiOperation("地点搜索 - 关键字")
	@ApiOperationSupport(order = 1)
	public ApiResult<BaseGpsQueryRes<PlaceSearchRes>> placeSearch(@RequestBody @Valid PlaceSearchReq req){
		BaseGpsQueryRes<PlaceSearchRes> res = gpsService.getPlaceSearch(req);
		return ApiResult.success(res);
	}

	@PostMapping("/explore")
	@ApiOperation("地点搜索 - 周边")
	@ApiOperationSupport(order = 2)
	public ApiResult<BaseGpsQueryRes<PlaceSearchRes>> explore(@RequestBody @Valid ExploreReq req){
		BaseGpsQueryRes<PlaceSearchRes> res = gpsService.getExplore(req);
		return ApiResult.success(res);
	}

	@PostMapping("/detail")
	@ApiOperation("地点搜索 - id")
	@ApiOperationSupport(order = 3)
	public ApiResult<BaseGpsQueryRes<PlaceSearchRes>> detail(@RequestBody @Valid ObjReq<String> dto){
		BaseGpsQueryRes<PlaceSearchRes> res = gpsService.getDetail(dto.getObj());
		return ApiResult.success(res);
	}

	@GetMapping("/splice1")
	@ApiOperation("分隔符 =============")
	@ApiOperationSupport(order = 10)
	public void splice1(){}

	@PostMapping("/suggestion")
	@ApiOperation("关键词搜索")
	@ApiOperationSupport(order = 11)
	public ApiResult<BaseGpsQueryRes<SuggestionRes>> suggestion(@RequestBody @Valid SuggestionReq req){
		BaseGpsQueryRes<SuggestionRes> res = gpsService.getSuggestion(req);
		return ApiResult.success(res);
	}

	@GetMapping("/splice2")
	@ApiOperation("分隔符 =============")
	@ApiOperationSupport(order = 20)
	public void splice2(){}

	@PostMapping("/addressResolve")
	@ApiOperation("地址解析(地址转坐标)")
	@ApiOperationSupport(order = 21)
	public ApiResult<BaseGpsQueryRes<AddressResolveRes>> addressResolve(@RequestBody @Valid ObjReq<String> req){
		BaseGpsQueryRes<AddressResolveRes> res = gpsService.addressResolve(req.getObj());
		return ApiResult.success(res);
	}

	@PostMapping("/locationResolve")
	@ApiOperation("逆地址解析(坐标描述)")
	@ApiOperationSupport(order = 22)
	public ApiResult<BaseGpsQueryRes<LocationResolveRes>> locationResolve(@RequestBody @Valid Location location){
		BaseGpsQueryRes<LocationResolveRes> res = gpsService.getLocationResolve(location);
		return ApiResult.success(res);
	}

	@GetMapping("/splice3")
	@ApiOperation("分隔符 =============")
	@ApiOperationSupport(order = 30)
	public void splice3(){}

	@PostMapping("/districtProvince")
	@ApiOperation("行政区划 - 所有 - 省")
	@ApiOperationSupport(order = 31)
	public ApiResult<List<DistrictRes>> districtListProvince(){
		List<DistrictRes> res = gpsService.districtListProvince();
		return ApiResult.success(res);
	}

	@PostMapping("/districtListCity")
	@ApiOperation("行政区划 - 所有 - 市")
	@ApiOperationSupport(order = 32)
	public ApiResult<List<DistrictRes>> districtListCity(){
		List<DistrictRes> res = gpsService.districtListCity();
		return ApiResult.success(res);
	}

	@PostMapping("/districtListArea")
	@ApiOperation("行政区划 - 所有 - 区")
	@ApiOperationSupport(order = 33)
	public ApiResult<List<DistrictRes>> districtListArea(){
		List<DistrictRes> res = gpsService.districtListArea();
		return ApiResult.success(res);
	}

//	@PostMapping("/resetMysqlDistrict")
//	@ApiOperation("行政区划 - 重设我的数据库的行政地区信息")
//	@ApiOperationSupport(order = 34)
//	public ApiResult<T> resetMysqlDistrict(){
//		gpsService.resetMysqlDistrict();
//		return ApiResult.success();
//	}
}
